﻿using Autofac;
using System;
using System.Collections.Generic;
using System.Text;

namespace VIP.Infrastructure
{
    public static class AutofacHelper
    {
        /// <summary>
        /// 注册scope依赖
        /// </summary>
        /// <typeparam name="TImplementer"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static ContainerBuilder RegScope<TImplementer, T>(this ContainerBuilder builder)
        {
            builder.RegisterType<TImplementer>().As<T>().InstancePerLifetimeScope();
            return builder;
        }
        public static ContainerBuilder RegSingleInstance<TImplementer, T>(this ContainerBuilder builder)
        {
            builder.RegisterType<TImplementer>().As<T>().SingleInstance();
            return builder;
        }
        
    }
}
